package com.mapper;

import com.pojo.FinishedProductInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 成品映射器
 *
 * @author 蔡文欣
 * @date 2023/06/23 09:16:18
 */
@Mapper
public interface FinishedProductMapper {
    /**
     * 获取成品信息
     *
     * @return {@link List}<{@link FinishedProductInfo}>
     */
    List<FinishedProductInfo> getFinishedProductInfo();


    /**
     * 按编码查询成品
     *
     * @param productId 产品ID
     * @return {@link FinishedProductInfo}
     */
    FinishedProductInfo queryFinishProductByCode(Long productId);
    @Select("select finished_product_id     finishedProductId,\n" +
            "               finished_product_code   finishedProductCode,\n" +
            "               finished_product_name   finishedProductName,\n" +
            "               warehouse_entry_time    warehouseEntryTime,\n" +
            "               warehouse_id            warehouseId,\n" +
            "               delivery_time           deliveryTime,\n" +
            "               finished_product_num    finishedProductNum,\n" +
            "               finished_product_detail finishedProductDetail,\n" +
            "               finished_product_actual finishedProductActual,\n" +
            "               cause cause,\n" +
            "               size_id sizeId\n" +
            "        from finished_product_info where finished_product_code=#{arg0} and size_id=#{arg1}")
    List<FinishedProductInfo> QueryFinishProductById(Long productId,Long size);

    /**
     * 修改实际库存   和原因
     *
     */
    int updateActual(String batchNumber,Long finishedProductActual);

    @Update("update finished_product_info set finished_product_num=#{arg1} where finished_product_id=#{arg0}")
    int updateNumber(Long id,Long number);

    int updateBatch(String random,Long finishedProductId);

    int updateCause(String batchNumber, Long finishedProductActual, String cause);
}
